package com.bckj.fastboot.paid.biz.application.consumer.pay.strategy;

import com.bckj.fastboot.core.jackson.JsonUtils;
import com.bckj.fastboot.mq.ons.OnsConsumeStrategy;
import com.bckj.fastboot.paid.api.constant.PayMQConstants;
import com.bckj.fastboot.paid.api.model.PayResult;
import com.bckj.fastboot.paid.api.model.PayResultMsg;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

@Component
public class PayResultOnsConsumeStrategy implements OnsConsumeStrategy {

    @Override
    @PostConstruct
    public void register() {
        PayOnsConsumeStrategyProvider.STRATEGY_MAP.put(getTag(), this);
    }

    @Override
    public String getTag() {
        return PayMQConstants.PAY_TAG_RESULT;
    }

    @Override
    public void consume(String msg) {
        PayResultMsg payResultMsg = JsonUtils.toBean(msg, PayResultMsg.class);
        PayResult payResult = payResultMsg.getPayResult();
        //通知下游
    }
}
